<template>
  <div>
    <div class="top">
      <div style="width: 60px" @click="returnTap">取消</div>
      <span>选择一个聊天</span>
      <span v-if="!isnum" @click="isnumTap">多选</span>
      <van-button
        v-if="isnum"
        type="info"
        style="height: 30px"
        @click="finishTap"
        >完成({{ arr.length }})</van-button
      >
    </div>
    <div class="input">
      <div class="inputList" v-if="arr != ''">
        <img src="../../assets/images/logo.png" v-for="item of arr" alt="" />
      </div>

      <input type="text" class="inputAl"  @focus="inputTap" placeholder="搜索" />
    </div>
    <div class="list" v-for="item of list">
      <div class="list1" v-if="isnum">
        <van-checkbox v-model="item.type" @change="checkBoxTap"></van-checkbox>
      </div>
      <div class="list_left" @click="coupshow = true">
        <van-badge :content="item.num">
          <img class="list_img" src="../../assets/images/logo.png" alt="" />
        </van-badge>
      </div>
      <div :class="isnum ? 'list_right' : 'list_right1'">
        <div class="col1">
          <span class="col2">小明</span>
          <span class="col3">2020-08-21</span>
        </div>
        <div class="col1">
          <span class="col4" v-if="item.status == 1">电话:1510000000</span>
          <span class="col5" v-if="item.status == 1">提醒</span>
        </div>
        <div class="col1">
          <span class="col3">[图片]</span>
          <!-- <span class="col3"></span> -->
        </div>
      </div>
      <van-overlay
        :show="coupshow"
        style="background: rgba(30, 30, 30, 0.2)"
        @click="coupshow = false"
      >
        <div class="wrapper" @click.stop>
          <div class="block">
            <div class="title">分别发送给：</div>
            <div class="wrapImg">
              <img
                class="wrapImg1"
                v-for="item of arr"
                :key="index"
                src="../../assets/images/logo.png"
                alt=""
              />
            </div>
            <div class="wrapimage">
              <img
                class="wrapimage1"
                src="../../assets/images/card.png"
                alt=""
              />
            </div>
            <div class="wrapinput">
              <input type="text" placeholder="给朋友留言" />
            </div>
            <div class="caozuo">
              <div @click="coupshow = false">取消</div>
              <div @click="coupshow = false" style="color: #7e89ab">
                发送{{ arr.length }}
              </div>
            </div>
          </div>
        </div>
      </van-overlay>
    </div>
  </div>
</template>
<script>
import { Dialog } from "vant";
export default {
  data() {
    return {
      list: [
        { name: "[图片]", num: 9, status: 0, type: false },
        { name: "[15条]丽丽: 明白", num: 10, status: 1, type: false },
        {
          name: "你好，如果你有任何建议或投诉，请点击此处反...",
          num: 2,
          status: 1,
          type: false,
        },
        { name: "[图片]", num: 9, status: 0, type: false },
      ],
      index: "",
      arr: [],
      isnum: false,
      coupshow: false,
    };
  },
  methods: {
    returnTap() {
      this.$router.go(-1);
    },
    checkBoxTap() {
      console.log(this.list);
      var list = this.list;
      var arr = [];
      for (var a = 0; a < list.length; a++) {
        if (list[a].type == true) {
          if (arr.length < 10) {
            arr.push(list[a]);
          } else {
            Dialog.alert({
              title: "提示",
              message: "最多只能选择9个聊天",
            }).then(() => {
              // on close
            });
          }
        }
      }
      this.arr = arr;
    },
    finishTap() {
      this.coupshow = true;
    },
    isnumTap() {
      this.isnum = true;
    },
        inputTap() {
      this.$router.push("/search");
    },
  },
};
</script>
<style scoped>
.top {
  height: 60px;
  width: 90%;
  padding: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  line-height: 60px;
  position: relative;
  background: #eeeeee;
}
.input {
  height: 50px;
  width: 100%;
  text-align: center;
  line-height: 50px;
  position: relative;
  background: #eeeeee;
}
.input_icon {
  position: absolute;
  left: 43%;
  top: 17px;
  font-size: 18px;
}
/* .inputAl::-webkit-input-placeholder {
  padding-left: 5%;
} */
.inputAl {
  height: 35px;
  width: 96%;
  border: none;
  text-align: center;
}
.list {
  height: 90px;
  width: 100%;
  border-bottom: 1px solid #e5e5e5;
  display: flex;
  align-items: center;
}
.list1 {
  display: flex;
  justify-content: center;
  width: 10%;
}
.list_left {
  width: 18%;
  margin-left: 3%;
  display: flex;
  flex-direction: column;
}
.list_img {
  width: 100%;
  height: 70px;
  border-radius: 10px;
}
.list_right {
  width: 64%;
}
.list_right1 {
  width: 75%;
}
.col1 {
  width: 100%;
  margin-left: 2%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 20px;
  font-size: 15px;
}
.col2 {
  font-weight: bold;
}
.col3 {
  font-size: 14px;
  color: #999999;
}
.col4,
.col5 {
  font-size: 14px;
  color: #000;
}
.inputList {
  position: absolute;
  left: 12px;
  top: 10px;
  display: flex;
  flex-wrap: wrap;
}
.inputList img {
  width: 30px;
  height: 30px;
  border-radius: 10%;
}
.wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.block {
  width: 80%;
  height: 400px;
  border-radius: 10px;
  background-color: #fff;
}
.title {
  height: 60px;
  line-height: 60px;
  font-size: 22px;
  margin-left: 3%;
}
.wrapImg {
  width: 94%;
  margin: 0 3%;
  padding-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid #eeeeee;
}
.wrapImg1 {
  width: 40px;
  height: 40px;
  border-radius: 5px;
}
.wrapimage {
  width: 100%;
  height: 180px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.wrapimage1 {
  width: 150px;
}
.wrapinput {
  height: 40px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.wrapinput input {
  width: 80%;
  border-radius: 50px;
  height: 30px;
  background: #f2f2f2;
  border: none;
  padding: 10px;
}
.caozuo {
  width: 100%;
  height: 70px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.caozuo div {
  width: 50%;
  text-align: center;
  font-weight: blod;
  font-size: 20px;
}
</style>